package sched

import (
	"pdocker/tool/sql"
	"time"

	log "github.com/sirupsen/logrus"
)

type TaskTable struct {
	TaskID    string                 `gorm:"primaryKey"`
	TimeStamp int64                  `json:"timestamp,omitempty"`
	CallBack  string                 `json:"callback,omitempty"`
	Data      map[string]interface{} `gorm:"serializer:json"`
}

var timerList map[string]*time.Timer

func init() {
	model := &TaskTable{}
	err := sql.PgDB.AutoMigrate(model)
	if err != nil {
		log.Errorln(err)
	} else {
		log.Debugf("创建表: %v", model)
	}

	timerList = make(map[string]*time.Timer)
}
